package com.iasku.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.iasku.entity.UserErrorBook;
import com.iasku.entity.UserHomework;
import com.iasku.iaskueleclass_phone.R;

public class ErrorBookAdapter extends BaseAdapter{
    private List<UserErrorBook> mData;
    private LayoutInflater mInflater;
    
    public ErrorBookAdapter(Context mContext,List<UserErrorBook> mData){
        this.mInflater = LayoutInflater.from(mContext);
        this.mData = mData;
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = this.mInflater.inflate(R.layout.errorbook_item,null);
            holder = new ViewHolder();
            holder.mErrorSubjectname = (TextView) convertView.findViewById(R.id.tv_error_subjectname);
            holder.mErrorQuestiontype = (TextView) convertView.findViewById(R.id.tv_error_questiontype);
            holder.mErrorSubmittime = (TextView) convertView.findViewById(R.id.tv_error_submittime);
            holder.mErrorGetscore = (TextView) convertView.findViewById(R.id.tv_error_getscore);
            holder.mErrorIscorrected = (TextView) convertView.findViewById(R.id.tv_error_iscorrected);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        UserErrorBook eQue = mData.get(position);
        holder.mErrorSubjectname.setText(eQue.getSubjectname());
        holder.mErrorQuestiontype.setText(eQue.getQuestionTypeName());
        holder.mErrorSubmittime.setText(eQue.getSubmitTime());
        holder.mErrorGetscore.setText(eQue.getGetScore());
        holder.mErrorIscorrected.setText(eQue.getIsCorrectedStr());
        return convertView;
    }
    
    private class ViewHolder{
        TextView mErrorSubjectname;
        TextView mErrorQuestiontype;
        TextView mErrorSubmittime;
        TextView mErrorGetscore;
        TextView mErrorIscorrected;
    }

}
